#-*- coding:utf-8 -*-
import os
import sys
from datetime import datetime as dt
def MSG(m):
    print("[%s]\t%s"%(dt.now().strftime("%H:%M:%S"),m))

def alert_module_not_install(module_name,download_page = None):
    if download_page:
        MSG("Please Install '%s' Module First! use 'pip install %s' or download *.whl from '%s'"%(module_name,module_name,download_page))
    else:
        MSG("Please Install '%s' Module First! use 'pip install %s'"%(module_name,module_name))    

def alert_module_pyMuPDF():
    alert_module_not_install("PyMuPDF","https://pypi.org/project/PyMuPDF/#files")

def alert_file_not_exists(file_name):
    MSG("File '%s' Not Found!"%file_name)

def test_file_exists(file_name):
    result = os.path.exists(file_name)
    if not result:
        alert_file_not_exists(file_name)
    return result
def test_pymupdf_imported():
    module_imported = False
    try:
        import fitz
        module_imported = True
    except:
        alert_module_pyMuPDF()
    return module_imported
def message_bar(msg):
    MSG(msg.join(['-'*20,'-'*20]))

def message_finished(msg="END"):
    message_bar(msg)
def message_started(msg="START"):
    message_bar(msg)